<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix='sec' uri='http://www.springframework.org/security/tags'%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript" src="scripts/boot.js"></script>
</head>
<body style="border: 0px; margin: 0px; padding: 0px;width: 100%;height: 100%">
<div class="mini-toolbar" style="border-bottom:0;padding:0px;">
    <table style="width:100%;">
        <tr>
            <td style="width:100%;">
             <sec:authorize url='/staff_export_salary.do'>
                <a class="mini-button" iconCls="icon-download" onclick="exports()">导出已选</a>
                <a class="mini-button" iconCls="icon-download" onclick="exportsAll()">导出所有</a>
             </sec:authorize>
              <sec:authorize url='/staff_salary_add.do'>
                <a class="mini-button" iconCls="icon-add" onclick="salaryAdd('生成员工薪资')">生成员工薪资</a>
                <span style="color: #f00;">（默认查询从当前时间前一个月的薪资）</span>
              </sec:authorize>
            </td>
            <td style="white-space:nowrap;">
                <input name="startTime" class="mini-datepicker" allowInput="false"/>&nbsp;至&nbsp;
                <input name="endTime" class="mini-datepicker" allowInput="false"/>
                <a class="mini-button" iconCls="icon-search" onclick="search()">查询</a>
            </td>
        </tr>
    </table>
</div>
<div class="mini-fit" >
	<div id="datagrid0921" class="mini-datagrid " idField="id" pageSize="20" allowAlternating="true"
		allowCellSelect="true" multiSelect="true" url="staff_salary_table_view.do" style="width:100%;height: 100%">
		<div property="columns">
			<div type="indexcolumn"></div>
			<div type="checkcolumn"></div>
			<div field="dept" width="10%" headerAlign="center" align="center">部门</div>
			<div field="platformName" width="10%" headerAlign="center" align="center">中心</div>
			<div field="groupName" width="10%" headerAlign="center" align="center">组</div>
			<div field="name" width="10%" headerAlign="center" align="center">姓名</div>
			<div field="positionName" width="10%" headerAlign="center" align="center">职务</div>
			<div field="basic" width="7%" headerAlign="center" align="center">基本工资</div>
			<div field="effectSalary" width="7%" headerAlign="center" align="center">绩效工资</div>
			<div field="leaveDeduct" width="7%" headerAlign="center" align="center">请假扣款</div>
			<div field="practicalSalary" width="7%" headerAlign="center" align="center">实发工资</div>
			<div field="calcStime" width="10%" dateFormat="yyyy-MM-dd" allowSort="true" headerAlign="center" align="center">工资计算开始时间</div>
			<div field="calcEtime" width="10%" dateFormat="yyyy-MM-dd" allowSort="true" headerAlign="center" align="center">工资计算结束时间</div>
		</div>
	</div>
</div>
<script type="text/javascript">
mini.parse();
var grid = mini.get("datagrid0921");
grid.load();

function search() {
	var startTime = mini.getbyName("startTime").getFormValue();
	var endTime = mini.getbyName("endTime").getFormValue();
	grid.load({stime: startTime, etime: endTime});
}

function exports() {
	var rows = grid.getSelecteds();
    if (rows.length > 0) {
       var ids = [];
       for (var i = 0, l = rows.length; i < l; i++) {
           var r = rows[i];
           ids.push(r.id);
       }
       var id = ids.join(',');
       location.href = "staff_export_salary.do?id="+id;
    } else {
       mini.alert("请选中一条记录");
    }
}

function exportsAll() {
	var startTime = mini.getbyName("startTime").getFormValue();
	var endTime = mini.getbyName("endTime").getFormValue();
	location.href = "staff_export_all_salary.do?id="+id+"&startTime="+startTime+"&endTime="+endTime;
}

function salaryAdd(title) {
    mini.open({
   		url: "staff_salary_add.do",
   		allowResize:false,
       	title: title, width: 500, height: 270,
       	onload: function () {
           var iframe = this.getIFrameEl();
           var data = { action: "new"};
           iframe.contentWindow.SetData(data);
   		},
	   	ondestroy: function (action) {
	   		if(action == 'succ'){
	   			mini.showMessageBox({
                    title: "提示",
                    showModal:false,
                    iconCls: "mini-messagebox-info",
                    message: "操作成功！",
                    timeout: 3000,
                    x: 'right',
                    y: 'bottom'
                });
	   			grid.load();
	   		}
        }
 	});
}
</script>
</body>
</html>